home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Bank smakow / BankSmakow.air / BankSmakow.swf / scripts / com / makingwaves / model / ModelLocator.as
Text File  |  2009-12-16  |  4KB  |  140 lines

  1. package com.makingwaves.model
  2. {
  3.    import com.adobe.cairngorm.model.IModelLocator;
  4.    import flash.events.Event;
  5.    import flash.events.EventDispatcher;
  6.    import flash.events.IEventDispatcher;
  7.    import flash.utils.Dictionary;
  8.    import mx.collections.ArrayCollection;
  9.    import mx.events.PropertyChangeEvent;
  10.    
  11.    public class ModelLocator implements IModelLocator, IEventDispatcher
  12.    {
  13.       
  14.       private static var allowInstantiation:Boolean;
  15.       
  16.       private static var instance:ModelLocator;
  17.        
  18.       
  19.       private var _selectedProducts:Dictionary;
  20.       
  21.       private var _bindingEventDispatcher:EventDispatcher;
  22.       
  23.       private var _recipes:ArrayCollection;
  24.       
  25.       private var _fridgeProducts:ArrayCollection;
  26.       
  27.       public function ModelLocator()
  28.       {
  29.          _bindingEventDispatcher = new EventDispatcher(IEventDispatcher(this));
  30.          super();
  31.          if(allowInstantiation)
  32.          {
  33.             _fridgeProducts = new ArrayCollection();
  34.             _recipes = new ArrayCollection();
  35.             return;
  36.          }
  37.          throw new Error("Use getInstance()");
  38.       }
  39.       
  40.       public static function getInstance() : ModelLocator
  41.       {
  42.          if(instance == null)
  43.          {
  44.             allowInstantiation = true;
  45.             instance = new ModelLocator();
  46.             allowInstantiation = false;
  47.          }
  48.          return instance;
  49.       }
  50.       
  51.       public function dispatchEvent(param1:Event) : Boolean
  52.       {
  53.          return _bindingEventDispatcher.dispatchEvent(param1);
  54.       }
  55.       
  56.       private function set _1335272161selectedProducts(param1:Dictionary) : void
  57.       {
  58.          _selectedProducts = param1;
  59.       }
  60.       
  61.       private function set _1082416293recipes(param1:ArrayCollection) : void
  62.       {
  63.          _recipes = param1;
  64.       }
  65.       
  66.       private function set _377251465fridgeProducts(param1:ArrayCollection) : void
  67.       {
  68.          _fridgeProducts = param1;
  69.       }
  70.       
  71.       public function willTrigger(param1:String) : Boolean
  72.       {
  73.          return _bindingEventDispatcher.willTrigger(param1);
  74.       }
  75.       
  76.       public function get fridgeProducts() : ArrayCollection
  77.       {
  78.          return _fridgeProducts;
  79.       }
  80.       
  81.       [Bindable(event="propertyChange")]
  82.       public function set recipes(param1:ArrayCollection) : void
  83.       {
  84.          var _loc2_:Object = this.recipes;
  85.          if(_loc2_ !== param1)
  86.          {
  87.             this._1082416293recipes = param1;
  88.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"recipes",_loc2_,param1));
  89.          }
  90.       }
  91.       
  92.       public function addEventListener(param1:String, param2:Function, param3:Boolean = false, param4:int = 0, param5:Boolean = false) : void
  93.       {
  94.          _bindingEventDispatcher.addEventListener(param1,param2,param3,param4,param5);
  95.       }
  96.       
  97.       public function removeEventListener(param1:String, param2:Function, param3:Boolean = false) : void
  98.       {
  99.          _bindingEventDispatcher.removeEventListener(param1,param2,param3);
  100.       }
  101.       
  102.       [Bindable(event="propertyChange")]
  103.       public function set fridgeProducts(param1:ArrayCollection) : void
  104.       {
  105.          var _loc2_:Object = this.fridgeProducts;
  106.          if(_loc2_ !== param1)
  107.          {
  108.             this._377251465fridgeProducts = param1;
  109.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"fridgeProducts",_loc2_,param1));
  110.          }
  111.       }
  112.       
  113.       public function get selectedProducts() : Dictionary
  114.       {
  115.          return _selectedProducts;
  116.       }
  117.       
  118.       public function get recipes() : ArrayCollection
  119.       {
  120.          return _recipes;
  121.       }
  122.       
  123.       public function hasEventListener(param1:String) : Boolean
  124.       {
  125.          return _bindingEventDispatcher.hasEventListener(param1);
  126.       }
  127.       
  128.       [Bindable(event="propertyChange")]
  129.       public function set selectedProducts(param1:Dictionary) : void
  130.       {
  131.          var _loc2_:Object = this.selectedProducts;
  132.          if(_loc2_ !== param1)
  133.          {
  134.             this._1335272161selectedProducts = param1;
  135.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"selectedProducts",_loc2_,param1));
  136.          }
  137.       }
  138.    }
  139. }
  140.